-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #2973: Check variances of class parents #4932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
case _ => defn.ObjectType // can happen if class files are missing | ||
} | ||
} | ||
tp.parents.map { p => transformedParent(apply(p)) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use { when ( works
tests/neg/i2973.scala
Outdated
@@ -0,0 +1,2 @@ | |||
class Foo[U] | |||
class Bar[-T] extends Foo[T] // error: contravariant type T occurs in invariant position |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More testcases (related to annotations, etc) would be nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't find any annotation for parent classes apart from @uncheckedVariance
. So added more tests for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just create a dummy annotation and use it wherever
In particular, this preserves @uncheckedVariance for the variance checker.
c5f8a6d
to
131b36c
Compare
Fix #2973: check variance of parent classes via
ClassInfo.classParents
(via @odersky's fix in #4057).To account for
@uncheckedVariance
(unlike #4057), preventNamer
from stripping annotations inclassParents
. Surprisingly, the rest of Dotty doesn't mind!We probably should test this on the new collections and the community build, since collections will stress this out much more.